﻿using Microsoft.AspNetCore.Authorization;

namespace Ocelot.Admin.Api.Application
{
    /// <summary>
    /// 全局配置接口
    /// </summary>
    public class GlobalConfigurationApiController : IDynamicApiController
    {
        private readonly IGlobalConfigurationService _globalConfigurationService;

        public GlobalConfigurationApiController(IGlobalConfigurationService globalConfigurationService)
        {
            _globalConfigurationService = globalConfigurationService;
        }

        #region 查询

        /// <summary>
        /// 查询全局配置信息
        /// </summary>
        /// <returns></returns>
        public async Task<GlobalConfiguration> GetGlobalConfigurationAsync()
        {
            return await _globalConfigurationService.GetGlobalConfigurationAsync();
        }

        #endregion

        #region 新增

        /// <summary>
        /// 新增全局配置信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<int> InsertGlobalConfigurationAsync(InsertGlobalConfigurationRequest request)
        {
            return await _globalConfigurationService.InsertGlobalConfigurationAsync(request);
        }

        #endregion

        #region 编辑

        /// <summary>
        /// 更新全局配置信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<string> UpdateGlobalConfigurationAsync(UpdateGlobalConfigurationRequest request)
        {
            return await _globalConfigurationService.UpdateGlobalConfigurationAsync(request);
        }

        #endregion

        #region 删除

        /// <summary>
        /// 删除全局配置信息
        /// </summary>
        /// <param name="globalConfigurationId">全局配置Id</param>
        /// <returns></returns>
        public async Task<string> DeletGlobalConfigurationAsync(int globalConfigurationId)
        {
            return await _globalConfigurationService.DeletGlobalConfigurationAsync(globalConfigurationId);
        }

        #endregion
    }
}